import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: '0.0.0.0', // 设置为 0.0.0.0 可以允许任何 IP 地址访问
    port: 16080,      // 设置端口号
    proxy: {  
      // 当你访问 '/api' 开头的路径时  
      '/api': {  
        // 目标服务器的地址  
        target: 'http://127.0.0.1:16010',  
        changeOrigin: true,  
      },
    }, 
  },
})
